<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>网点管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    #parse('/headFiles.html')
</head>
<body>
<div class="layui-form" style="padding: 20px 15px 0 0;" id="layer-photos" wid100>
    <input type="hidden" name="id" value="$!{id}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">实体店名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input"
                   value="$!{name}">
        </div>
    </div>
    #if(!$id)
    <div class="layui-row">
        <div class="layui-col-sm4">
            <div class="layui-form-item">
                <label class="layui-form-label">代理姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="user.name" lay-verify="required" autocomplete="off" class="layui-input"
                           value="$!{user.name}">
                </div>
            </div>
        </div>
        <div class="layui-col-sm4">
            <div class="layui-form-item">
                <label class="layui-form-label">代理手机号</label>
                <div class="layui-input-block">
                    <input type="text" name="user.phone" lay-verify="required" autocomplete="off" class="layui-input"
                           value="$!{user.phone}">
                </div>
            </div>
        </div>
    </div>
    #end
    <div class="layui-form-item">
        <label class="layui-form-label">实体店场景图</label>
        <div class="layui-input-block">
            <input type="text" name="thumbnailImg" class="form-control" value="$!{thumbnailImg}">
        </div>
    </div>
    <div class="layui-form-item ">
        <label class="layui-form-label">实体店类型</label>
        <div class="layui-input-block" id="typeCodes"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">省市地区</label>
        <div class="layui-input-block" id="areaCode"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">经纬度</label>
        <div class="layui-input-inline"><input type="text" name="longitude" placeholder="经度"
                                               autocomplete="off" class="layui-input" value="$!{longitude}"></div>
        <div class="layui-input-inline"><input type="text" name="latitude" placeholder="纬度"
                                               autocomplete="off" class="layui-input" value="$!{latitude}"></div>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="btnOpenAMap">打开地图</button>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">详细地址</label>
        <div class="layui-input-block">
            <textarea name="address" autocomplete="off" class="layui-textarea" style="min-height:50px;">$!{address}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">路线信息</label>
        <div class="layui-input-block">
            <textarea name="routeInfo" autocomplete="off" class="layui-textarea" style="min-height:50px;">$!{routeInfo}</textarea>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-sm4">
            <div class="layui-form-item">
                <label class="layui-form-label">开门时间(24H)</label>
                <div class="layui-input-block">
                    <input type="text" name="openTime" lay-verify="required" autocomplete="off" class="layui-input"
                           value="6" placeholder="请输入开门时间，24小时制，只支持整点">
                </div>
            </div>
        </div>
        <div class="layui-col-sm4">
            <div class="layui-form-item">
                <label class="layui-form-label">关门时间(24H)</label>
                <div class="layui-input-block">
                    <input type="text" name="closeTime" lay-verify="required" autocomplete="off" class="layui-input"
                           value="22" placeholder="请输入关闭时间，24小时制，只支持整点">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-form-submit" id="LAY-form-submit" value="确定">
    </div>
</div>
#parse('/footFiles.html')
<script type="text/javascript">
    layui.config({
        base: '$!{webRoot}/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'selectM', 'selectN', 'upload'], function () {
        var $ = layui.$, selectM = layui.selectM, selectN = layui.selectN, form = layui.form, upload = layui.upload;

        $('input[name="thumbnailImg"]').jfFileManager({
            resDomain:'${resDomain}',
            token:'$!{resToken}',
            multiple:false,
            path:'/device/images',
            parent:parent
        });

        selectN({
            elem: '#areaCode'
            , name: 'areaCode'
            , search: [true, true]
            , selected: '$!{areaCode}'
            , data: '$!{webRoot}/common/china/area/tree/select.data'
            , field: {
                idName: 'id',
                titleName: 'name',
                statusName: 'status',
                childName: 'children'
            }
        });

        selectN({
            elem: '#typeCodes'
            , name: 'typeCodes'
            , search: [true, true]
            , selected: '$!{typeCodes}'
            , data: '$!{webRoot}/place/physical_store/type/select.data'
            , field: {
                idName: 'code',
                titleName: 'name',
                statusName: 'status',
                childName: 'children'
            }
        });

        $('#btnOpenAMap').click(function () {
            parent.layer.open({
                type: 2
                , title: '地图'
                , content: '$!{webRoot}/place/gps/map.html?placeId=$!{id}'
                , maxmin: true
                , shade: 0
                , area: ['60%', '80%']
                , btn: ['确定', '取消']
                , yes: function (index, layero) {
                    var iframeWindow = parent.window['layui-layer-iframe' + index]
                        , submit = layero.find('iframe').contents().find("#LAY-form-submit");
                    iframeWindow.layui.form.on('submit(LAY-form-submit)', function (data) {
                        var field = data.field;
                        $('input[name="longitude"]').val(field.longitude);
                        $('input[name="latitude"]').val(field.latitude);
                        parent.layer.close(index);
                    });
                    submit.trigger('click');
                }
                , zIndex: layer.zIndex
            });
        });
    });
</script>
</body>
</html>